package org.yaac.server.egql;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

/**
 * @author Max Zhu (thebbsky@gmail.com)
 *
 */
public class FromClause implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 
	 */
	private List<FromEntity> fromEntities;
	
	/**
	 * 
	 */
	public FromClause() {
		fromEntities = new LinkedList<FromEntity>();
	}

	/**
	 * @param e
	 * @return
	 */
	public FromClause add(FromEntity e) {
		fromEntities.add(e);
		return this;
	}

	/**
	 * @return
	 */
	public List<FromEntity> getFromEntities() {
		return fromEntities;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((fromEntities == null) ? 0 : fromEntities.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FromClause other = (FromClause) obj;
		if (fromEntities == null) {
			if (other.fromEntities != null)
				return false;
		} else if (!fromEntities.equals(other.fromEntities))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "FromClause [fromEntities=" + fromEntities + "]";
	}
}
